package com.kempca.moviecenter.ui;

import com.kempca.moviecenter.io.MovieFileAccess;

import javafx.scene.layout.BorderPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;


import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.effect.Lighting;
import javafx.scene.effect.Reflection;
import javafx.scene.effect.Shadow;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.util.Duration;

public class MovieCenter extends Application {
	
	private int fullScreenReduction = 75;

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		
		MovieFileAccess mfa = new MovieFileAccess();
		mfa.loadAllMedia();
		
		Group root = new Group();
		Scene scene = new Scene(root,  Screen.getPrimary().getBounds().getWidth(), Screen.getPrimary().getBounds().getHeight() - fullScreenReduction, Color.BLACK);
		
		Button button = new Button();
		button.setText("OK");
		button.setEffect(new Reflection());
		
		//Media video = new Media("C:/Users/Christopher/Downloads/FFDP.flv");
		Media video = new Media("http://encoding.com.result.s3.amazonaws.com/0651cd76ceb85f17c4fd405638c1cfbf_1255_22341862.flv");
		MediaPlayer mediaPlayer = new MediaPlayer(video);
		MediaView mediaView = new MediaView(mediaPlayer);  
		mediaView.setFitHeight(mediaView.getFitHeight()/2);
		mediaView.setFitWidth(mediaView.getFitWidth()/2);
		mediaView.setEffect(new Reflection());
		//root.getChildren().add(mediaPlayer);
		
		/*final Timeline timeline = new Timeline();
		timeline.setCycleCount(Timeline.INDEFINITE);
		timeline.setAutoReverse(true);
		final KeyValue kv = new KeyValue(button.opacityProperty(), 0);
		final KeyFrame kf = new KeyFrame(Duration.millis(200), kv);
		timeline.getKeyFrames().add(kf);
		timeline.play();*/
		
		mediaPlayer.play();
		
		root.getChildren().add(mediaView);
		
		primaryStage.setScene(scene);
		primaryStage.setFullScreen(true);
		
		primaryStage.show();

	}
	


}
